package com.ianmoone.juc;


public class MaoTest {
	public static int a =0;
	public static void main(String[] args) {
		threadDemo demo1 = new threadDemo();
		threadDemo demo2 = new threadDemo();
		
		for (int i = 0; i < 10; i++) {
			demo1.start();
			demo2.start();
			System.out.println(a);
			
			a=0;
			demo1 = new threadDemo();
			demo2 = new threadDemo();
		}
	}
	
}
class threadDemo extends Thread{
	@Override
	public void run() {
		boolean isOdd = false;

		for(int i=1;i<=2;++i)
		{
		if(i%2==1)isOdd = true;
		else isOdd = false;
		MaoTest.a+=i*(isOdd?1:-1);
		}
		
	}
	
}
